<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$lotto_id = intval($_GET['id']);
$userid = $curruser['id'];
$userlist = GetUserList($userid);
if ($userlist == "")
{
    exit("Not Users!");
    exit();
}
$conf = new Config();
$stopbet = $conf->get("stopbet");
if (!isset($_SESSION['saystopmod']))
{
    $_SESSION['saystopmod'] = 0;
}
$saystopmod = $_SESSION['saystopmod'];
if ($stopbet <= date("Hi") && !$saystopmod)
{
    $saystopmod = 1;
    $_SESSION['saystopmod'] = $saystopmod;
    echo "-1";
    exit();
}
$maxbet_hint = intval($conf->get("max_bat_hint"));
$split = 1;
$ratemod = 2;
$disk_code = "a";
$diskStr = "";
include( "class_6h/BetTotal_6h.php" );
$BetTotal_6h = new BetTotal_6h($lotto_id);
$dataTotalArr = array();
$showDataArr = array();
$i = 1;
while ($i < 12)
{
    $showDataArr[$i] = array();
    $showDataArr[$i]['1'] = array("numbers" => "{$i}_1", "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "rate" => 0, "back1" => 0, "back2" => 0, "winlost" => 0, "namount" => "");
    $showDataArr[$i]['2'] = array("numbers" => "{$i}_2", "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "rate" => 0, "back1" => 0, "back2" => 0, "winlost" => 0, "namount" => "");
    $dataTotalArr[$i] = array("bettype" => $i, "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "back1" => 0, "back2" => 0);
    ++$i;
}
$theacl = $curruser['acl'];
$userid = $curruser['id'];
$showid = $theacl == 255 ? "0" : $userid;
$bettypeStr = "19";
$sql = $BetTotal_6h->getDataListByNumSsSQL($lotto_id, $bettypeStr, $showid, $diskStr, $split, $ratemod);
$rs = getdb($sql);
$updatetime = systime() - 30;
while (!$rs->eof)
{
    $bettype = $rs->f['bettype'];
    $n = substr($rs->f['numbers'], 0, 1);
    $i = intval(substr($rs->f['numbers'], 2, 2));
    $showDataArr[$i][$n]['totalnum'] = $rs->f['totalnum'];
    $showDataArr[$i][$n]['amount'] = $rs->f['amount'];
    $showDataArr[$i][$n]['amount_rate'] = $rs->f['amount_rate'];
    $showDataArr[$i][$n]['rate'] = $rs->f['rate'];
    $dataTotalArr[$i]['totalnum'] += $rs->f['totalnum'];
    $dataTotalArr[$i]['amount'] += $rs->f['amount'];
    $dataTotalArr[$i]['back1'] += $rs->f['back1'];
    $dataTotalArr[$i]['back2'] += $rs->f['back2'];
    $rs->next();
}
$rs->close();
$rs = getdb("select * from rate1a where lotto_id={$lotto_id}");
if ($rs->eof)
{
    exit("Error ID!");
}
$rs1 = get_srates_data($userid, $lotto_id, 1);
if ($rs1->eof)
{
    exit("Error ID!");
}
$i = 1;
while ($i < 12)
{
    $idx = d2($i);
    $showDataArr[$i][1]['rate'] = $rs->f["r19_1_{$idx}"] - $rs1->f["r19_1_{$idx}"] - 0;
    $showDataArr[$i][2]['rate'] = $rs->f["r19_2_{$idx}"] - $rs1->f["r19_2_{$idx}"] - 0;
    ++$i;
}
$rs->close();
$rs1->close();
$i = 1;
while ($i < 12)
{
    echo $dataTotalArr[$i]['amount'] - $dataTotalArr[$i]['back1'] + $dataTotalArr[$i]['back2'];
    echo "," . $showDataArr[$i][1]['rate'] . "@" . $showDataArr[$i][1]['totalnum'] . "@" . $showDataArr[$i][1]['amount'];
    echo "@" . $showDataArr[$i][1]['amount_rate'];
    echo "," . $showDataArr[$i][2]['rate'] . "@" . $showDataArr[$i][2]['totalnum'] . "@" . $showDataArr[$i][2]['amount'];
    echo "@" . $showDataArr[$i][2]['amount_rate'];
    echo "\n";
    ++$i;
}
include( "class_6h/class.menu.php" );
$fieldArr = array("lotto_id" => $lotto_id, "split_id" => 1);
$onlineMenu = new menu_6h(11, $fieldArr);
echo $onlineMenu->getMenuAmu();
echo "\n";
exit();